home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / WFC010.ZIP / SRC / CFILET~1.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-06  |  3.5 KB  |  200 lines

  1. #include <wfc.h>
  2. #pragma hdrstop
  3.  
  4. /*
  5. ** Author: Samuel R. Blackburn
  6. ** CI$: 76300,326
  7. ** Internet: sammy@sed.csc.com
  8. **
  9. ** You can use it any way you like as long as you don't try to sell it.
  10. **
  11. ** Any attempt to sell WFC in source code form must have the permission
  12. ** of the original author. You can produce commercial executables with
  13. ** WFC but you can't sell WFC.
  14. **
  15. ** Copyright, 1995, Samuel R. Blackburn
  16. **
  17. ** $Workfile: $
  18. ** $Revision: $
  19. ** $Modtime: $
  20. */
  21.  
  22. #if defined( _DEBUG )
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. #if defined( _DEBUG )
  28. #define new DEBUG_NEW
  29. #endif
  30.  
  31. CFileTime::CFileTime()
  32. {
  33.    Empty();
  34. }
  35.  
  36. CFileTime::CFileTime( const CFileTime& source )
  37. {
  38.    Copy( source );
  39. }
  40.  
  41. CFileTime::CFileTime( const CSystemTime& source )
  42. {
  43.    Copy( source );
  44. }
  45.  
  46. CFileTime::CFileTime( const FILETIME * source )
  47. {
  48.    Copy( source );
  49. }
  50.  
  51. CFileTime::CFileTime( const SYSTEMTIME * source )
  52. {
  53.    Copy( source );
  54. }
  55.  
  56. CFileTime::CFileTime( WORD ms_dos_date, WORD ms_dos_time )
  57. {
  58.    Copy( ms_dos_date, ms_dos_time );
  59. }
  60.  
  61. CFileTime::~CFileTime()
  62. {
  63.    Empty();
  64. }
  65.  
  66. LONG CFileTime::Compare( const CFileTime& source )
  67. {
  68.    return( ::CompareFileTime( (const FILETIME *) this, (const FILETIME *) &source ) );
  69. }
  70.  
  71. void CFileTime::Copy( const CFileTime& source )
  72. {
  73.    Copy( (const FILETIME *) &source );
  74. }
  75.  
  76. void CFileTime::Copy( const CSystemTime& source )
  77. {
  78.    Copy( (const SYSTEMTIME *) &source );
  79. }
  80.  
  81. void CFileTime::Copy( const FILETIME * source )
  82. {
  83.    ASSERT( source != NULL );
  84.  
  85.    if ( source == (const FILETIME *) NULL )
  86.    {
  87.       Empty();
  88.       return;
  89.    }
  90.  
  91.    dwLowDateTime  = source->dwLowDateTime;
  92.    dwHighDateTime = source->dwHighDateTime;
  93. }
  94.  
  95. void CFileTime::Copy( const SYSTEMTIME * source )
  96. {
  97.    ASSERT( source != NULL );
  98.  
  99.    if ( source == (const SYSTEMTIME *) NULL )
  100.    {
  101.       Empty();
  102.       return;
  103.    }
  104.  
  105.    FILETIME file_time;
  106.  
  107.    if ( ::SystemTimeToFileTime( source, &file_time ) == TRUE )
  108.    {
  109.       Copy( &file_time );
  110.    }
  111.    else
  112.    {
  113.       Empty();
  114.    }
  115. }
  116.  
  117. void CFileTime::Copy( WORD ms_dos_date, WORD ms_dos_time )
  118. {
  119.    FILETIME file_time;
  120.  
  121.    if ( ::DosDateTimeToFileTime( ms_dos_date, ms_dos_time, &file_time ) == TRUE )
  122.    {
  123.       Copy( &file_time );
  124.    }
  125.    else
  126.    {
  127.       Empty();
  128.    }
  129. }
  130.  
  131. void CFileTime::Empty( void )
  132. {
  133.    dwLowDateTime  = 0;
  134.    dwHighDateTime = 0;
  135. }
  136.  
  137. /*
  138. ** Operators
  139. */
  140.  
  141. CFileTime& CFileTime::operator = ( const CFileTime& source )
  142. {
  143.    Copy( source );
  144.    return( *this );
  145. }
  146.  
  147. CFileTime& CFileTime::operator = ( const CSystemTime& source )
  148. {
  149.    Copy( source );
  150.    return( *this );
  151. }
  152.  
  153. BOOL CFileTime::operator == ( const CFileTime& source )
  154. {
  155.    if ( Compare( source ) == 0 )
  156.    {
  157.       return( TRUE );
  158.    }
  159.    else
  160.    {
  161.       return( FALSE );
  162.    }
  163. }
  164.  
  165. BOOL CFileTime::operator < ( const CFileTime& source )
  166. {
  167.    if ( Compare( source ) < 0 )
  168.    {
  169.       return( TRUE );
  170.    }
  171.    else
  172.    {
  173.       return( FALSE );
  174.    }
  175. }
  176.  
  177. BOOL CFileTime::operator > ( const CFileTime& source )
  178. {
  179.    if ( Compare( source ) > 0 )
  180.    {
  181.       return( TRUE );
  182.    }
  183.    else
  184.    {
  185.       return( FALSE );
  186.    }
  187. }
  188.  
  189. #if defined( _DEBUG )
  190.  
  191. void CFileTime::Dump( CDumpContext& dump_context ) const
  192. {
  193.    dump_context << "a CFileTime ar " << (VOID *) this << "\n{\n";
  194.    dump_context << "   dwLowDateTime is " << dwLowDateTime << "\n";
  195.    dump_context << "   dwHighDateTime is " << dwHighDateTime << "\n";
  196.    dump_context << "}\n";
  197. }
  198.  
  199. #endif
  200.